# ============================================================
# by howlink *
# Filename       : addListener.sh
#
# Description: get oracle home by sid
# exmple: ./getOraHome.sh orcl
# =============================================================
#! /bin/bash

if [ $# -lt 1 ]; then
   exit 1
fi

sid=$1

os=`uname -s`
otab=/etc/oratab

if [ $os = "SunOS" ]; then
   otab=/var/opt/oracle/oratab
fi

home=`cat /opt/howlink/lb-agent/application.properties | grep "^agent.oracle-home" | awk -F'=' '{ print $2 }' | sed 's/ //g'`
if [ -z "$home" ];then
    home=`echo $ORACLE_HOME`
fi

if [ "$home"="" ];then
    home=`grep -wi "$sid:"  $otab | grep "^$sid" | head -n1 | cut -f2 -d":"`
fi

echo $home
